@SuppressWarnings("unchecked")
public class Text {
    public static int NodeCount3(BNTreeClass bt) // 基于后序遍历求结点个数
    {
        return NodeCount31(bt.b);
    }

    private static int NodeCount31(BNTree<Character> t) {
        int m, n, k;
        if (t == null) // 空树结点个数为0
            return 0;
        m = NodeCount31(t.lchild); // 遍历求左子树的结点个数
        n = NodeCount31(t.rchild); // 遍历求右子树的结点个数
        k = 1; // 根结点计数1，相当于访问根结点
        return k + m + n;
    }

    public static void main(String[] args) {
        String s = "A(B(D(,G)),C(E,F))";
        BNTreeClass bt = new BNTreeClass();
        bt.CreateBNTree(s);
        System.out.println("bt: " + bt.toString());
        System.out.println("NodeCount3求出结点个数: " + NodeCount3(bt));
    }
}